package ar.com.photo_admin.domain

import ar.com.photo_admin.domain.price_strategies.*;
import grails.plugins.springsecurity.Secured

@Secured(['ROLE_PHOTOGRAPHER'])
class PhotographerConfigurationController {

	def photographerConfigurationService
	
	def springSecurityService
	
    def index() {
		redirect(action: "configuration")
	}
	
	
	def configuration() {
		def photographerInstance = springSecurityService.getCurrentUser()
		[photographerInstance: photographerInstance]
	}
	
	def save() {						
		Photographer photographerInstance  = springSecurityService.getCurrentUser()		 		
		photographerInstance.properties = params						

		if (photographerInstance.hasErrors() || !photographerInstance.save(flush: true)) {
			render(view: "configuration", model: [photographerInstance: photographerInstance])
			return
		}
		
		flash.message = message(code: 'photographer.configuration.prices.update')
		render(view: "configuration", model: [photographerInstance: photographerInstance])
	}
}
